/**
 * 系统常量定义
 */

// 设备状态
export const DEVICE_STATUS = {
  ONLINE: 'online',
  OFFLINE: 'offline',
  CONNECTING: 'connecting',
  ERROR: 'error',
  UNKNOWN: 'unknown'
}

// 设备状态标签
export const DEVICE_STATUS_LABELS = {
  [DEVICE_STATUS.ONLINE]: '在线',
  [DEVICE_STATUS.OFFLINE]: '离线',
  [DEVICE_STATUS.CONNECTING]: '连接中',
  [DEVICE_STATUS.ERROR]: '错误',
  [DEVICE_STATUS.UNKNOWN]: '未知'
}

// 设备状态颜色
export const DEVICE_STATUS_COLORS = {
  [DEVICE_STATUS.ONLINE]: 'success',
  [DEVICE_STATUS.OFFLINE]: 'danger',
  [DEVICE_STATUS.CONNECTING]: 'warning',
  [DEVICE_STATUS.ERROR]: 'danger',
  [DEVICE_STATUS.UNKNOWN]: 'info'
}

// 通道状态
export const CHANNEL_STATUS = {
  ACTIVE: 'active',
  INACTIVE: 'inactive',
  STREAMING: 'streaming',
  ERROR: 'error'
}

// 通道状态标签
export const CHANNEL_STATUS_LABELS = {
  [CHANNEL_STATUS.ACTIVE]: '活跃',
  [CHANNEL_STATUS.INACTIVE]: '非活跃',
  [CHANNEL_STATUS.STREAMING]: '流媒体中',
  [CHANNEL_STATUS.ERROR]: '错误'
}

// 通道状态颜色
export const CHANNEL_STATUS_COLORS = {
  [CHANNEL_STATUS.ACTIVE]: 'success',
  [CHANNEL_STATUS.INACTIVE]: 'info',
  [CHANNEL_STATUS.STREAMING]: 'primary',
  [CHANNEL_STATUS.ERROR]: 'danger'
}

// 流格式
export const STREAM_FORMATS = {
  HLS: 'hls',
  MJPEG: 'mjpeg',
  RTMP: 'rtmp',
  WEBRTC: 'webrtc',
  RTSP: 'rtsp'
}

// 流格式标签
export const STREAM_FORMAT_LABELS = {
  [STREAM_FORMATS.HLS]: 'HLS',
  [STREAM_FORMATS.MJPEG]: 'MJPEG',
  [STREAM_FORMATS.RTMP]: 'RTMP',
  [STREAM_FORMATS.WEBRTC]: 'WebRTC',
  [STREAM_FORMATS.RTSP]: 'RTSP'
}

// 视频质量
export const VIDEO_QUALITY = {
  HIGH: 'high',
  MEDIUM: 'medium',
  LOW: 'low',
  CUSTOM: 'custom'
}

// 视频质量标签
export const VIDEO_QUALITY_LABELS = {
  [VIDEO_QUALITY.HIGH]: '高清',
  [VIDEO_QUALITY.MEDIUM]: '标清',
  [VIDEO_QUALITY.LOW]: '流畅',
  [VIDEO_QUALITY.CUSTOM]: '自定义'
}

// 分辨率选项
export const RESOLUTION_OPTIONS = [
  { label: '4K (3840x2160)', value: '3840x2160' },
  { label: '2K (2560x1440)', value: '2560x1440' },
  { label: '1080P (1920x1080)', value: '1920x1080' },
  { label: '720P (1280x720)', value: '1280x720' },
  { label: '480P (854x480)', value: '854x480' },
  { label: '360P (640x360)', value: '640x360' },
  { label: '240P (426x240)', value: '426x240' }
]

// 帧率选项
export const FRAMERATE_OPTIONS = [
  { label: '60 FPS', value: 60 },
  { label: '30 FPS', value: 30 },
  { label: '25 FPS', value: 25 },
  { label: '20 FPS', value: 20 },
  { label: '15 FPS', value: 15 },
  { label: '10 FPS', value: 10 },
  { label: '5 FPS', value: 5 }
]

// 比特率选项（Kbps）
export const BITRATE_OPTIONS = [
  { label: '8 Mbps', value: 8000 },
  { label: '6 Mbps', value: 6000 },
  { label: '4 Mbps', value: 4000 },
  { label: '2 Mbps', value: 2000 },
  { label: '1 Mbps', value: 1000 },
  { label: '512 Kbps', value: 512 },
  { label: '256 Kbps', value: 256 }
]

// 设备类型
export const DEVICE_TYPES = {
  CAMERA: 'camera',
  NVR: 'nvr',
  DVR: 'dvr',
  ENCODER: 'encoder',
  DECODER: 'decoder',
  OTHER: 'other'
}

// 设备类型标签
export const DEVICE_TYPE_LABELS = {
  [DEVICE_TYPES.CAMERA]: '摄像头',
  [DEVICE_TYPES.NVR]: '网络录像机',
  [DEVICE_TYPES.DVR]: '数字录像机',
  [DEVICE_TYPES.ENCODER]: '编码器',
  [DEVICE_TYPES.DECODER]: '解码器',
  [DEVICE_TYPES.OTHER]: '其他'
}

// 制造商列表
export const MANUFACTURERS = [
  'Hikvision',
  'Dahua',
  'Axis',
  'Bosch',
  'Sony',
  'Panasonic',
  'Samsung',
  'Honeywell',
  'Pelco',
  'Vivotek',
  'Uniview',
  'Tiandy',
  'Other'
]

// PTZ控制命令
export const PTZ_COMMANDS = {
  UP: 'up',
  DOWN: 'down',
  LEFT: 'left',
  RIGHT: 'right',
  ZOOM_IN: 'zoom_in',
  ZOOM_OUT: 'zoom_out',
  FOCUS_NEAR: 'focus_near',
  FOCUS_FAR: 'focus_far',
  IRIS_OPEN: 'iris_open',
  IRIS_CLOSE: 'iris_close',
  STOP: 'stop'
}

// PTZ控制命令标签
export const PTZ_COMMAND_LABELS = {
  [PTZ_COMMANDS.UP]: '向上',
  [PTZ_COMMANDS.DOWN]: '向下',
  [PTZ_COMMANDS.LEFT]: '向左',
  [PTZ_COMMANDS.RIGHT]: '向右',
  [PTZ_COMMANDS.ZOOM_IN]: '放大',
  [PTZ_COMMANDS.ZOOM_OUT]: '缩小',
  [PTZ_COMMANDS.FOCUS_NEAR]: '近焦',
  [PTZ_COMMANDS.FOCUS_FAR]: '远焦',
  [PTZ_COMMANDS.IRIS_OPEN]: '光圈开',
  [PTZ_COMMANDS.IRIS_CLOSE]: '光圈关',
  [PTZ_COMMANDS.STOP]: '停止'
}

// 录制状态
export const RECORDING_STATUS = {
  RECORDING: 'recording',
  STOPPED: 'stopped',
  PAUSED: 'paused',
  ERROR: 'error'
}

// 录制状态标签
export const RECORDING_STATUS_LABELS = {
  [RECORDING_STATUS.RECORDING]: '录制中',
  [RECORDING_STATUS.STOPPED]: '已停止',
  [RECORDING_STATUS.PAUSED]: '已暂停',
  [RECORDING_STATUS.ERROR]: '错误'
}

// 录制状态颜色
export const RECORDING_STATUS_COLORS = {
  [RECORDING_STATUS.RECORDING]: 'success',
  [RECORDING_STATUS.STOPPED]: 'info',
  [RECORDING_STATUS.PAUSED]: 'warning',
  [RECORDING_STATUS.ERROR]: 'danger'
}

// 事件类型
export const EVENT_TYPES = {
  MOTION_DETECTION: 'motion_detection',
  LINE_CROSSING: 'line_crossing',
  INTRUSION_DETECTION: 'intrusion_detection',
  FACE_DETECTION: 'face_detection',
  VEHICLE_DETECTION: 'vehicle_detection',
  AUDIO_DETECTION: 'audio_detection',
  TAMPERING: 'tampering',
  SYSTEM_ERROR: 'system_error',
  DEVICE_OFFLINE: 'device_offline',
  STORAGE_FULL: 'storage_full'
}

// 事件类型标签
export const EVENT_TYPE_LABELS = {
  [EVENT_TYPES.MOTION_DETECTION]: '移动检测',
  [EVENT_TYPES.LINE_CROSSING]: '越线检测',
  [EVENT_TYPES.INTRUSION_DETECTION]: '入侵检测',
  [EVENT_TYPES.FACE_DETECTION]: '人脸检测',
  [EVENT_TYPES.VEHICLE_DETECTION]: '车辆检测',
  [EVENT_TYPES.AUDIO_DETECTION]: '音频检测',
  [EVENT_TYPES.TAMPERING]: '遮挡检测',
  [EVENT_TYPES.SYSTEM_ERROR]: '系统错误',
  [EVENT_TYPES.DEVICE_OFFLINE]: '设备离线',
  [EVENT_TYPES.STORAGE_FULL]: '存储空间满'
}

// 事件级别
export const EVENT_LEVELS = {
  LOW: 'low',
  MEDIUM: 'medium',
  HIGH: 'high',
  CRITICAL: 'critical'
}

// 事件级别标签
export const EVENT_LEVEL_LABELS = {
  [EVENT_LEVELS.LOW]: '低',
  [EVENT_LEVELS.MEDIUM]: '中',
  [EVENT_LEVELS.HIGH]: '高',
  [EVENT_LEVELS.CRITICAL]: '严重'
}

// 事件级别颜色
export const EVENT_LEVEL_COLORS = {
  [EVENT_LEVELS.LOW]: 'info',
  [EVENT_LEVELS.MEDIUM]: 'warning',
  [EVENT_LEVELS.HIGH]: 'danger',
  [EVENT_LEVELS.CRITICAL]: 'danger'
}

// 网络协议
export const NETWORK_PROTOCOLS = {
  HTTP: 'http',
  HTTPS: 'https',
  RTSP: 'rtsp',
  RTMP: 'rtmp',
  TCP: 'tcp',
  UDP: 'udp'
}

// 认证类型
export const AUTH_TYPES = {
  NONE: 'none',
  BASIC: 'basic',
  DIGEST: 'digest',
  WSSE: 'wsse'
}

// 认证类型标签
export const AUTH_TYPE_LABELS = {
  [AUTH_TYPES.NONE]: '无认证',
  [AUTH_TYPES.BASIC]: 'Basic认证',
  [AUTH_TYPES.DIGEST]: 'Digest认证',
  [AUTH_TYPES.WSSE]: 'WS-Security认证'
}

// 日志级别
export const LOG_LEVELS = {
  TRACE: 'trace',
  DEBUG: 'debug',
  INFO: 'info',
  WARN: 'warn',
  ERROR: 'error',
  FATAL: 'fatal'
}

// 日志级别标签
export const LOG_LEVEL_LABELS = {
  [LOG_LEVELS.TRACE]: '跟踪',
  [LOG_LEVELS.DEBUG]: '调试',
  [LOG_LEVELS.INFO]: '信息',
  [LOG_LEVELS.WARN]: '警告',
  [LOG_LEVELS.ERROR]: '错误',
  [LOG_LEVELS.FATAL]: '致命'
}

// 日志级别颜色
export const LOG_LEVEL_COLORS = {
  [LOG_LEVELS.TRACE]: 'info',
  [LOG_LEVELS.DEBUG]: 'primary',
  [LOG_LEVELS.INFO]: 'success',
  [LOG_LEVELS.WARN]: 'warning',
  [LOG_LEVELS.ERROR]: 'danger',
  [LOG_LEVELS.FATAL]: 'danger'
}

// 存储类型
export const STORAGE_TYPES = {
  LOCAL: 'local',
  NAS: 'nas',
  CLOUD: 'cloud',
  FTP: 'ftp',
  SFTP: 'sftp'
}

// 存储类型标签
export const STORAGE_TYPE_LABELS = {
  [STORAGE_TYPES.LOCAL]: '本地存储',
  [STORAGE_TYPES.NAS]: 'NAS存储',
  [STORAGE_TYPES.CLOUD]: '云存储',
  [STORAGE_TYPES.FTP]: 'FTP存储',
  [STORAGE_TYPES.SFTP]: 'SFTP存储'
}

// 文件格式
export const FILE_FORMATS = {
  MP4: 'mp4',
  AVI: 'avi',
  MOV: 'mov',
  MKV: 'mkv',
  FLV: 'flv',
  TS: 'ts',
  M3U8: 'm3u8'
}

// 音频编码
export const AUDIO_CODECS = {
  AAC: 'aac',
  MP3: 'mp3',
  G711A: 'g711a',
  G711U: 'g711u',
  G726: 'g726',
  OPUS: 'opus'
}

// 视频编码
export const VIDEO_CODECS = {
  H264: 'h264',
  H265: 'h265',
  MJPEG: 'mjpeg',
  MPEG4: 'mpeg4'
}

// 时间格式
export const TIME_FORMATS = {
  DATETIME: 'YYYY-MM-DD HH:mm:ss',
  DATE: 'YYYY-MM-DD',
  TIME: 'HH:mm:ss',
  DATETIME_SHORT: 'MM-DD HH:mm',
  TIME_SHORT: 'HH:mm'
}

// 分页配置
export const PAGINATION = {
  DEFAULT_PAGE: 1,
  DEFAULT_SIZE: 20,
  SIZE_OPTIONS: [10, 20, 50, 100]
}

// 请求超时时间（毫秒）
export const TIMEOUTS = {
  DEFAULT: 30000,
  UPLOAD: 300000,
  DOWNLOAD: 300000,
  DISCOVERY: 60000,
  STREAMING: 10000
}

// 本地存储键名
export const STORAGE_KEYS = {
  TOKEN: 'onvif_token',
  USER_INFO: 'onvif_user_info',
  SETTINGS: 'onvif_settings',
  THEME: 'onvif_theme',
  LANGUAGE: 'onvif_language',
  SIDEBAR_COLLAPSED: 'onvif_sidebar_collapsed',
  DEVICE_FILTERS: 'onvif_device_filters',
  CHANNEL_FILTERS: 'onvif_channel_filters'
}

// 主题配置
export const THEMES = {
  LIGHT: 'light',
  DARK: 'dark',
  AUTO: 'auto'
}

// 主题标签
export const THEME_LABELS = {
  [THEMES.LIGHT]: '浅色主题',
  [THEMES.DARK]: '深色主题',
  [THEMES.AUTO]: '跟随系统'
}

// 语言配置
export const LANGUAGES = {
  ZH_CN: 'zh-cn',
  EN_US: 'en-us'
}

// 语言标签
export const LANGUAGE_LABELS = {
  [LANGUAGES.ZH_CN]: '简体中文',
  [LANGUAGES.EN_US]: 'English'
}

// 默认配置
export const DEFAULTS = {
  DEVICE_PORT: 80,
  STREAM_PORT: 554,
  DISCOVERY_TIMEOUT: 30,
  CONNECTION_TIMEOUT: 10,
  RETRY_COUNT: 3,
  RETRY_DELAY: 1000,
  HEARTBEAT_INTERVAL: 30,
  REFRESH_INTERVAL: 60
}

// 正则表达式
export const REGEX = {
  IP: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
  PORT: /^([1-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/,
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  URL: /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/,
  MAC: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
}

// 错误代码
export const ERROR_CODES = {
  NETWORK_ERROR: 'NETWORK_ERROR',
  TIMEOUT_ERROR: 'TIMEOUT_ERROR',
  AUTH_ERROR: 'AUTH_ERROR',
  PERMISSION_ERROR: 'PERMISSION_ERROR',
  NOT_FOUND_ERROR: 'NOT_FOUND_ERROR',
  SERVER_ERROR: 'SERVER_ERROR',
  VALIDATION_ERROR: 'VALIDATION_ERROR',
  DEVICE_OFFLINE: 'DEVICE_OFFLINE',
  STREAM_ERROR: 'STREAM_ERROR'
}

// 错误消息
export const ERROR_MESSAGES = {
  [ERROR_CODES.NETWORK_ERROR]: '网络连接错误',
  [ERROR_CODES.TIMEOUT_ERROR]: '请求超时',
  [ERROR_CODES.AUTH_ERROR]: '认证失败',
  [ERROR_CODES.PERMISSION_ERROR]: '权限不足',
  [ERROR_CODES.NOT_FOUND_ERROR]: '资源不存在',
  [ERROR_CODES.SERVER_ERROR]: '服务器内部错误',
  [ERROR_CODES.VALIDATION_ERROR]: '数据验证失败',
  [ERROR_CODES.DEVICE_OFFLINE]: '设备离线',
  [ERROR_CODES.STREAM_ERROR]: '流媒体错误'
}

// 成功消息
export const SUCCESS_MESSAGES = {
  DEVICE_ADDED: '设备添加成功',
  DEVICE_UPDATED: '设备更新成功',
  DEVICE_DELETED: '设备删除成功',
  DEVICE_ENABLED: '设备启用成功',
  DEVICE_DISABLED: '设备禁用成功',
  CHANNEL_UPDATED: '通道更新成功',
  CHANNEL_ENABLED: '通道启用成功',
  CHANNEL_DISABLED: '通道禁用成功',
  SETTINGS_SAVED: '设置保存成功',
  BACKUP_CREATED: '备份创建成功',
  BACKUP_RESTORED: '备份恢复成功',
  FILE_UPLOADED: '文件上传成功',
  FILE_DOWNLOADED: '文件下载成功'
}
